package 转圈游戏;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int x = in.nextInt();
        System.out.println((x + qmi(10, k, n) * m) % n);
    }

    private static long qmi(long a, int b, int p) {
        long ret = 1 % p;
        while (b > 0) {
            if ((b & 1) == 1) {
                ret = ret * a % p;
            }
            a = a * a % p;
            b >>= 1;
        }
        return ret;
    }
}
